﻿using FangChanCrm.Services.Interface;
using FangChanCrm.Services.Realization;
using FangChanCrmModel;
using Maticsoft.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;

namespace FangChanCrm.Controllers
{
    public class PhoneTongJiController : Controller
    {
        private readonly It_XiaoShouBiaoService t_XiaoShouBiaoService;
        private readonly It_RenYuanBiaoService t_RenYuanBiaoService;
        private readonly It_XiaoShouXiangXiBiaoService t_XiaoShouXiangXiBiaoService;
        private readonly It_KeHuBiaoService t_KeHuBiaoService;
        private readonly It_TuanDuiBiaoService t_TuanDuiBiaoService;
        private readonly It_BuMenBiaoService t_BuMenBiaoService;
        private readonly It_TuanDuiRenYuanGuanLianBiaoService t_TuanDuiRenYuanGuanLianBiaoService;

        public PhoneTongJiController(It_XiaoShouBiaoService xiaoShouBiaoService, It_RenYuanBiaoService renYuanBiaoService, It_XiaoShouXiangXiBiaoService xiaoShouXiangXiBiaoService, It_KeHuBiaoService keHuBiaoService, It_TuanDuiBiaoService tuanDuiBiaoService, It_BuMenBiaoService buMenBiaoService, It_TuanDuiRenYuanGuanLianBiaoService tuanDuiRenYuanGuanLianBiaoService)
        {
            t_XiaoShouBiaoService = xiaoShouBiaoService;
            t_RenYuanBiaoService = renYuanBiaoService;
            t_XiaoShouXiangXiBiaoService = xiaoShouXiangXiBiaoService;
            t_KeHuBiaoService = keHuBiaoService;
            t_TuanDuiBiaoService = tuanDuiBiaoService;
            t_BuMenBiaoService = buMenBiaoService;
            t_TuanDuiRenYuanGuanLianBiaoService = tuanDuiRenYuanGuanLianBiaoService;
        }

        public IActionResult TongJi()
        {
            ViewData["LoginId"] = HttpContext.Session.GetString("loginid");
            return View();
        }

        public IActionResult ZYDaoFangJiLu()
        {
            return View();
        }

        public IActionResult GenJinQingKuang()
        {
            var listzong = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "跟进" && x.XiaoShouDongZuo == "确认到访").ToList();
            ViewBag.GenJinShuByMonth = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-30) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.DaoFangShuByMonth = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-30) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.GenJinShuByWeek = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-7) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.DaoFangShuuByWeek = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-7) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.GenJinShuByDay = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 00:00:00") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 23:59:59")).ToList().Count;
            ViewBag.DaoFangShuByDay = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 00:00:00") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 23:59:59")).ToList().Count;
            return View();
        }

        public IActionResult DaoFangQingKuang()
        {
            var listzong = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "跟进" && x.XiaoShouDongZuo == "确认到访").ToList();
            ViewBag.GenJinShuByMonth = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-30) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.DaoFangShuByMonth = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-30) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.GenJinShuByWeek = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-7) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.DaoFangShuuByWeek = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > DateTime.Now.AddDays(-7) && Convert.ToDateTime(x.CaoZuoShiJian) < DateTime.Now).ToList().Count;
            ViewBag.GenJinShuByDay = listzong.Where(x => x.XiaoShouDongZuo == "跟进" && Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 00:00:00") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 23:59:59")).ToList().Count;
            ViewBag.DaoFangShuByDay = listzong.Where(x => x.XiaoShouDongZuo == "确认到访" && Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 00:00:00") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 23:59:59")).ToList().Count;
            return View();
        }

        [HttpPost]
        public string ReturnQianDan()
        {
            var Returnlist = new List<ReturnList>();
            ReturnList returnList1 = new ReturnList();
            var Person = t_RenYuanBiaoService.GetById(Convert.ToInt32(HttpContext.Session.GetString("loginid")));
            var GangWeiMingCheng = Person.t_GangWeiBiao.GangWeiMingCheng;
            returnList1.Name = Person.XingMing;
            if (GangWeiMingCheng == "业务员")
            {
                var list = t_XiaoShouBiaoService.GetList().Where(x => x.YeWuYuanId == Convert.ToInt32(HttpContext.Session.GetString("loginid")) && x.ZhuangTai == "已完成").ToList();
                returnList1.Max = list.Count;
                returnList1.Min = list.Where(x => Convert.ToDateTime(x.ShengChengShiJian) > Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day + 1)).ToString("yyyy-MM-dd") + " 23:59:59")).ToList().Count;
                Returnlist.Add(returnList1);
            }
            else if (GangWeiMingCheng == "置业顾问")
            {
                var list = t_XiaoShouBiaoService.GetList().Where(x => x.ZhiYeGuWenId == Convert.ToInt32(HttpContext.Session.GetString("loginid")) && x.ZhuangTai == "已完成").ToList();
                returnList1.Max = list.Count;
                returnList1.Min = list.Where(x => Convert.ToDateTime(x.ShengChengShiJian) > Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day + 1)).ToString("yyyy-MM-dd") + " 23:59:59")).ToList().Count;
                Returnlist.Add(returnList1);
            }
            else
            {
                var AllPerson = t_RenYuanBiaoService.GetList().Where(x => x.t_GangWeiBiao.GangWeiMingCheng == "" || x.t_GangWeiBiao.GangWeiMingCheng == "");
                foreach (var item in AllPerson)
                {
                    ReturnList returnList2 = new ReturnList
                    {
                        Name = item.XingMing
                    };
                    var list = t_XiaoShouBiaoService.GetList().Where(x => x.ZhiYeGuWenId == item.Id && x.ZhuangTai == "已完成").ToList();
                    returnList2.Max = list.Count;
                    returnList2.Min = list.Where(x => Convert.ToDateTime(x.ShengChengShiJian) > Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day + 1)).ToString("yyyy-MM-dd") + " 23:59:59")).ToList().Count;
                    Returnlist.Add(returnList2);
                }
            }
            var dasfsd = JsonConvert.SerializeObject(Returnlist);
            string name = "";
            string max = "";
            string min = "";
            foreach (var item in Returnlist)
            {
                name = name + "\"" + item.Name + "\",";
                max = max + "\"" + item.Max + "\",";
                min = min + "\"" + item.Min + "\",";
            }
            if (Returnlist.Count != 0)
            {
                return "{\"Name\": [" + name[0..^1] + "],\"Max\": [" + max[0..^1] + "],\"Min\": [" + min[0..^1] + "]}";
            }
            else
            {
                return "{\"Name\": [" + name + "],\"Max\": [" + "0" + "],\"Min\": [" + "0" + "]}";
            }
        }
        [HttpPost]
        public string ReturnPaiMing()
        {
            var people = t_RenYuanBiaoService.GetById(Convert.ToInt32(HttpContext.Session.GetString("loginid")));
            var gangweiid = people.GangWeiId;
            var gangweiming = people.t_GangWeiBiao.GangWeiMingCheng;
            var Peoples = t_RenYuanBiaoService.GetList().Where(x => x.GangWeiId == gangweiid);
            List<int> Count = new List<int>();
            int myselfcount = 0;
            if (gangweiming == "业务员")
            {
                foreach (var item in Peoples)
                {
                    var ct = t_XiaoShouBiaoService.GetList().Where(x => x.YeWuYuanId == item.Id).ToList().Count;
                    Count.Add(ct);
                    if (item.Id == people.Id)
                    {
                        myselfcount = ct;
                    }
                }
            }
            else if (gangweiming == "置业顾问")
            {
                foreach (var item in Peoples)
                {
                    var ct = t_XiaoShouBiaoService.GetList().Where(x => x.YeWuYuanId == item.Id).ToList().Count;
                    Count.Add(ct);
                    if (item.Id == people.Id)
                    {
                        myselfcount = ct;
                    }
                }
            }
            Count.Sort();
            for (int i = 0; i < Count.Count; i++)
            {
                if (Count[i] == myselfcount)
                {
                    return "{	\"All\": \"" + Count.Count + "\",	\"My\": \"" + (i + 1) + "\"}";
                }
            }
            return "{\"All\": \"\",	\"My\": \"\"}";
        }
        [HttpPost]
        public string ReturnDaoFang()
        {
            var countall = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.CaoZuoRen == Convert.ToInt32(HttpContext.Session.GetString("loginid")) && x.XiaoShouDongZuo == "到访").ToList().Count;
            var countmounth = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.CaoZuoRen == Convert.ToInt32(HttpContext.Session.GetString("loginid")) && x.XiaoShouDongZuo == "到访" && Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.AddDays(-(DateTime.Now.Day + 1)).ToString("yyyy-MM-dd") + " 23:59:59")).ToList().Count;
            return "{	\"All\": \"" + countall + "\",	\"Mounth\": \"" + countmounth + "\"}";
        }
        [HttpPost]
        public string GenJinCiShu()
        {
            int one = 0, two = 0, three = 0, four = 0, five = 0, six = 0, seven = 0, eight = 0, nine = 0, ten = 0;
            var list = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.CaoZuoRen == Convert.ToInt32(HttpContext.Session.GetString("loginid")) && x.XiaoShouDongZuo == "跟进").ToList();
            var listdis = list.DistinctBy(x => x.XiaoShouBiaoId).ToList();
            for (int i = 0; i < listdis.Count; i++)
            {
                int count0 = list.Where(x => x.XiaoShouBiaoId == listdis[i].XiaoShouBiaoId).ToList().Count;
                if (count0 == 1)
                {
                    one++;
                }
                if (count0 == 2)
                {
                    two++;
                }
                if (count0 == 3)
                {
                    three++;
                }
                if (count0 == 4)
                {
                    four++;
                }
                if (count0 == 5)
                {
                    five++;
                }
                if (count0 == 6)
                {
                    six++;
                }
                if (count0 == 7)
                {
                    seven++;
                }
                if (count0 == 8)
                {
                    eight++;
                }
                if (count0 == 9)
                {
                    nine++;
                }
                if (count0 > 9)
                {
                    ten++;
                }
            }
            string count = "[1," + one + "],[2," + two + "],[3," + three + "],[4," + four + "],[5," + five + "],[6," + six + "],[7," + seven + "],[8," + eight + "],[9," + nine + "],[10," + ten + "]";
            return "{\"All\": [" + count + "]}";
        }
        [HttpPost]
        public string GetLaiFang()
        {
            var list = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "到访" && x.CaoZuoRen == Convert.ToInt32(HttpContext.Session.GetString("loginid"))).ToList();
            string type = Request.Form["GetJsonBy"];
            string strdate = "";
            string strdata = "";
            switch (type)
            {
                case "日":
                    for (int i = 0; i < DateTime.Now.Day; i++)
                    {
                        strdate = strdate + "\"" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + "\",";
                        strdata = strdata + "\"" + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59").AddDays(-1) && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59")).ToList().Count + "\",";
                    }
                    break;
                case "月":
                    for (int i = 0; i < DateTime.Now.Month; i++)
                    {
                        strdate = strdate + (i + 1) + "月,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i) && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i + 1)).ToList().Count + ",";
                    }
                    break;
                case "年":
                    for (int i = 2020; i <= DateTime.Now.Year; i++)
                    {
                        strdate = strdate + DateTime.Now.AddMonths(-(DateTime.Now.Month - 1 - i)).Month + "年,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year - 1 - i + 2020 + "/" + "12/31 23:59:59") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime((DateTime.Now.Year - i + 2020) + "/" + "12/31 23:59:59")).ToList().Count + ",";
                    }
                    break;
                default:
                    break;
            }
            return "{\"All\": " + "[" + strdate[0..^1] + "]" + ",	\"Data\": " + "[" + strdata[0..^1] + "]" + "}";
        }
        [HttpPost]
        public string GenJinKeHuShu()
        {
            var list = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "跟进" && x.CaoZuoRen == Convert.ToInt32(HttpContext.Session.GetString("loginid"))).DistinctBy(x => x.XiaoShouBiaoId).ToList();
            string type = Request.Form["GetJsonBy"];
            string strdate = "";
            string strdata = "";
            switch (type)
            {
                case "日":
                    for (int i = 0; i < DateTime.Now.Day; i++)
                    {
                        strdate = strdate + "\"" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + "\",";
                        strdata = strdata + "\"" + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59").AddDays(-1) && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59")).ToList().Count + "\",";
                    }
                    break;
                case "月":
                    for (int i = 0; i < DateTime.Now.Month; i++)
                    {
                        strdate = strdate + (i + 1) + "月,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i) && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i + 1)).ToList().Count + ",";
                    }
                    break;
                case "年":
                    for (int i = 2020; i <= DateTime.Now.Year; i++)
                    {
                        strdate = strdate + DateTime.Now.AddMonths(-(DateTime.Now.Month - 1 - i)).Month + "年,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) > Convert.ToDateTime(DateTime.Now.Year - 1 - i + 2020 + "/" + "12/31 23:59:59") && Convert.ToDateTime(x.CaoZuoShiJian) < Convert.ToDateTime((DateTime.Now.Year - i + 2020) + "/" + "12/31 23:59:59")).ToList().Count + ",";
                    }
                    break;
                default:
                    break;
            }
            return "{\"All\": " + "[" + strdate[0..^1] + "]" + ",	\"Data\": " + "[" + strdata[0..^1] + "]" + "}";
        }
        [HttpPost]
        public string KeHuLaiFangLeiXing()
        {
            List<t_XiaoShouBiao> listxiaoshou = new List<t_XiaoShouBiao>();
            if (t_RenYuanBiaoService.GetById(Convert.ToInt32(HttpContext.Session.GetString("loginid"))).t_GangWeiBiao.GangWeiMingCheng == "业务员")
            {
                listxiaoshou = t_XiaoShouBiaoService.GetList().Where(x => x.YeWuYuanId == Convert.ToInt32(HttpContext.Session.GetString("loginid"))).ToList();
            }
            else if (t_RenYuanBiaoService.GetById(Convert.ToInt32(HttpContext.Session.GetString("loginid"))).t_GangWeiBiao.GangWeiMingCheng == "置业顾问")
            {
                listxiaoshou = t_XiaoShouBiaoService.GetList().Where(x => x.ZhiYeGuWenId == Convert.ToInt32(HttpContext.Session.GetString("loginid"))).ToList();
            }
            var listxiaoshouxiangxi = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "到访").ToList();
            int shou = 0, fu = 0;
            if (listxiaoshou.Count == 0)
            {
                return "{\"All\":[{\"value\":\"0\",\"name\":\"首次访问\"},{\"value\":\"0\",\"name\":\"复访客户\"}]}";
            }
            else
            {
                for (int i = 0; i < listxiaoshou.Count; i++)
                {
                    var count = listxiaoshouxiangxi.Where(x => x.XiaoShouBiaoId == listxiaoshou[i].Id).ToList().Count;
                    if (count > 1)
                    {
                        fu++;
                    }
                    else if (count == 1)
                    {
                        shou++;
                    }
                }
                return "{\"All\":[{\"value\":\"" + shou + "\",\"name\":\"首次访问\"},{\"value\":\"" + fu + "\",\"name\":\"复访客户\"}]}";
            }
        }
        [HttpPost]
        public string XinZengKeHuShu()
        {
            var list = t_KeHuBiaoService.GetList().ToList();
            string type = Request.Form["GetJsonBy"];
            string strdate = "";
            string strdata = "";
            switch (type)
            {
                case "日":
                    for (int i = 0; i < DateTime.Now.Day; i++)
                    {
                        strdate = strdate + "\"" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + "\",";
                        strdata = strdata + "\"" + list.Where(x => Convert.ToDateTime(x.BeiZhu1) > Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59").AddDays(-1) && Convert.ToDateTime(x.BeiZhu1) < Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.AddDays(-(DateTime.Now.Day - 1 - i)).Day + " 23:59:59")).ToList().Count + "\",";
                    }
                    break;
                case "月":
                    for (int i = 0; i < DateTime.Now.Month; i++)
                    {
                        strdate = strdate + (i + 1) + "月,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.BeiZhu1) > Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i) && Convert.ToDateTime(x.BeiZhu1) < Convert.ToDateTime(DateTime.Now.Year - 1 + "/" + "12/31 23:59:59").AddMonths(i + 1)).ToList().Count + ",";
                    }
                    break;
                case "年":
                    for (int i = 2020; i <= DateTime.Now.Year; i++)
                    {
                        strdate = strdate + DateTime.Now.AddMonths(-(DateTime.Now.Month - 1 - i)).Month + "年,";
                        strdata = strdata + list.Where(x => Convert.ToDateTime(x.BeiZhu1) > Convert.ToDateTime(DateTime.Now.Year - 1 - i + 2020 + "/" + "12/31 23:59:59") && Convert.ToDateTime(x.BeiZhu1) < Convert.ToDateTime((DateTime.Now.Year - i + 2020) + "/" + "12/31 23:59:59")).ToList().Count + ",";
                    }
                    break;
                default:
                    break;
            }
            return "{\"All\": " + "[" + strdate[0..^1] + "]" + ",	\"Data\": " + "[" + strdata[0..^1] + "]" + "}";
        }

        public string ZyBangDingShuJu()
        {
            int loginid = Convert.ToInt32(HttpContext.Session.GetString("loginid"));
            //int loginid = 25;
            List<t_XiaoShouXiangXiBiao> listxiaoshouxiangxi = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.CaoZuoRen == loginid && x.XiaoShouDongZuo == "确认到访").OrderByDescending(c => c.CaoZuoShiJian).ToList();
            string json = "[";
            for (int i = 0; i < listxiaoshouxiangxi.Count; i++)
            {
                t_RenYuanBiao renyuan = t_RenYuanBiaoService.GetById(Convert.ToInt32(listxiaoshouxiangxi[i].CaoZuoRen));
                t_XiaoShouBiao xsbiao = t_XiaoShouBiaoService.GetById(listxiaoshouxiangxi[i].XiaoShouBiaoId);
                t_KeHuBiao kh = t_KeHuBiaoService.GetById(xsbiao.KeHuId);
                if (listxiaoshouxiangxi[i].XiaoShouDongZuo == "确认到访")
                {
                    json += "{\"XiaoShouDongZuo\":\"" + listxiaoshouxiangxi[i].XiaoShouDongZuo + "\",\"CaoZuoShiJian\":\"" + listxiaoshouxiangxi[i].CaoZuoShiJian + "\",\"MiaoShu\":\"" + listxiaoshouxiangxi[i].MiaoShu + "\",\"CaoZuoRen\":\"" + renyuan.XingMing + "\",\"CaoZuoRenDianHua\":\"" + renyuan.LianXiFangShi + "\",\"QueRenZhuangTai\":\"" + listxiaoshouxiangxi[i].ZhuangTai + "\",\"KeHuXingMing\":\"" + kh.KeHuXingMing + "\",\"ShouJiHaoMa\":\"" + kh.ShouJiHaoMa + "\"}";
                }
                if ((i + 1) == listxiaoshouxiangxi.Count)
                {

                }
                else
                {
                    json += ",";
                }

            }
            json += "]";

            return json;
        }
        [HttpPost]
        public string GetGenJinAndDaoFangList()
        {
            var LoginId = Convert.ToInt32(HttpContext.Session.GetString("loginid"));
            var RenYuanList = t_RenYuanBiaoService.GetList();
            List<ReturnForGenJinDaoFangTongJi> returnForGenJinDaoFangTongJis = new List<ReturnForGenJinDaoFangTongJi>();
            var TuanDuiBiao = t_TuanDuiBiaoService.GetList();
            var xiaoshouxiangxilist = t_XiaoShouXiangXiBiaoService.GetList().Where(x => x.XiaoShouDongZuo == "跟进" || x.XiaoShouDongZuo == "确认到访").ToList();
            for (int i = 0; i < 3; i++)
            {
                var StartTime = DateTime.Now;
                var EndTime = Convert.ToDateTime(DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + " 00:00:00").AddDays(1);
                if (i == 0)
                {
                    StartTime = EndTime.AddDays(-1);
                }
                else if (i == 1)
                {
                    StartTime = EndTime.AddDays(-7);
                }
                else
                {
                    StartTime = EndTime.AddDays(-30);
                }
                var TuanDuiBiaoGetAList = TuanDuiBiao.Where(x => x.JingLiId == LoginId).ToList();
                if (TuanDuiBiaoGetAList.Count > 0)
                {
                    var YuanGongList = new List<t_RenYuanBiao>();
                    foreach (var item in TuanDuiBiaoGetAList)
                    {
                        foreach (var item0 in item.t_TuanDuiRenYuanGuanLianBiaos)
                        {
                            t_RenYuanBiao t_RenYuanBiao = new t_RenYuanBiao();
                            t_RenYuanBiao.Id = item0.t_RenYuanBiao.Id;
                            t_RenYuanBiao.XingMing = item0.t_RenYuanBiao.XingMing;
                            t_RenYuanBiao.ZhangHao = item0.t_RenYuanBiao.ZhangHao;
                            t_RenYuanBiao.MiMa = item0.t_RenYuanBiao.MiMa;
                            t_RenYuanBiao.NianLing = item0.t_RenYuanBiao.NianLing;
                            t_RenYuanBiao.XingBie = item0.t_RenYuanBiao.XingBie;
                            t_RenYuanBiao.LianXiFangShi = item0.t_RenYuanBiao.LianXiFangShi;
                            t_RenYuanBiao.GangWeiId = item0.t_RenYuanBiao.GangWeiId;
                            t_RenYuanBiao.ZhanQuId = item0.t_RenYuanBiao.ZhanQuId;
                            t_RenYuanBiao.ZhanDuiId = item0.t_RenYuanBiao.ZhanDuiId;
                            t_RenYuanBiao.ZhuangTai = item0.t_RenYuanBiao.ZhuangTai;
                            t_RenYuanBiao.XingJi = item0.t_RenYuanBiao.XingJi;
                            t_RenYuanBiao.HunYinZhuangKuang = item0.t_RenYuanBiao.HunYinZhuangKuang;
                            t_RenYuanBiao.WeiXinHao = item0.t_RenYuanBiao.WeiXinHao;
                            t_RenYuanBiao.YouXiang = item0.t_RenYuanBiao.YouXiang;
                            t_RenYuanBiao.ShenFenZhengHao = item0.t_RenYuanBiao.ShenFenZhengHao;
                            t_RenYuanBiao.JiaTingDiZhi = item0.t_RenYuanBiao.JiaTingDiZhi;
                            t_RenYuanBiao.XueLi = item0.t_RenYuanBiao.XueLi;
                            YuanGongList.Add(t_RenYuanBiao);
                        }
                    }
                    returnForGenJinDaoFangTongJis.Add(new ReturnForGenJinDaoFangTongJi { PeopleType = "案场领导", ZhiYeGuWens = YuanGongList });
                }
                else
                {
                    var GongSiLingDaoList = RenYuanList.Where(x => x.t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng == "城市总" || x.t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng == "董事会").ToList();
                    var IfGongSiLingDaoHasLoginPeopleList = GongSiLingDaoList.Where(x => x.Id == LoginId).ToList();
                    if (IfGongSiLingDaoHasLoginPeopleList.Count > 0)
                    {
                        var allzhiyeguwen = RenYuanList.Where(x => x.t_GangWeiBiao.GangWeiMingCheng == "置业顾问").ToList();
                        var YuanGongList0 = new List<t_RenYuanBiao>();
                        foreach (var item0 in allzhiyeguwen)
                        {
                            t_RenYuanBiao t_RenYuanBiao = new t_RenYuanBiao();
                            t_RenYuanBiao.Id = item0.Id;
                            t_RenYuanBiao.XingMing = item0.XingMing;
                            t_RenYuanBiao.ZhangHao = item0.ZhangHao;
                            t_RenYuanBiao.MiMa = item0.MiMa;
                            t_RenYuanBiao.NianLing = item0.NianLing;
                            t_RenYuanBiao.XingBie = item0.XingBie;
                            t_RenYuanBiao.LianXiFangShi = item0.LianXiFangShi;
                            t_RenYuanBiao.GangWeiId = item0.GangWeiId;
                            t_RenYuanBiao.ZhanQuId = item0.ZhanQuId;
                            t_RenYuanBiao.ZhanDuiId = item0.ZhanDuiId;
                            t_RenYuanBiao.ZhuangTai = item0.ZhuangTai;
                            t_RenYuanBiao.XingJi = item0.XingJi;
                            t_RenYuanBiao.HunYinZhuangKuang = item0.HunYinZhuangKuang;
                            t_RenYuanBiao.WeiXinHao = item0.WeiXinHao;
                            t_RenYuanBiao.YouXiang = item0.YouXiang;
                            t_RenYuanBiao.ShenFenZhengHao = item0.ShenFenZhengHao;
                            t_RenYuanBiao.JiaTingDiZhi = item0.JiaTingDiZhi;
                            t_RenYuanBiao.XueLi = item0.XueLi;
                            YuanGongList0.Add(t_RenYuanBiao);
                        }
                        var allyewuyuan = RenYuanList.Where(x => x.t_GangWeiBiao.GangWeiMingCheng == "业务员").ToList();
                        var YuanGongList1 = new List<t_RenYuanBiao>();
                        foreach (var item0 in allyewuyuan)
                        {
                            t_RenYuanBiao t_RenYuanBiao = new t_RenYuanBiao();
                            t_RenYuanBiao.Id = item0.Id;
                            t_RenYuanBiao.XingMing = item0.XingMing;
                            t_RenYuanBiao.ZhangHao = item0.ZhangHao;
                            t_RenYuanBiao.MiMa = item0.MiMa;
                            t_RenYuanBiao.NianLing = item0.NianLing;
                            t_RenYuanBiao.XingBie = item0.XingBie;
                            t_RenYuanBiao.LianXiFangShi = item0.LianXiFangShi;
                            t_RenYuanBiao.GangWeiId = item0.GangWeiId;
                            t_RenYuanBiao.ZhanQuId = item0.ZhanQuId;
                            t_RenYuanBiao.ZhanDuiId = item0.ZhanDuiId;
                            t_RenYuanBiao.ZhuangTai = item0.ZhuangTai;
                            t_RenYuanBiao.XingJi = item0.XingJi;
                            t_RenYuanBiao.HunYinZhuangKuang = item0.HunYinZhuangKuang;
                            t_RenYuanBiao.WeiXinHao = item0.WeiXinHao;
                            t_RenYuanBiao.YouXiang = item0.YouXiang;
                            t_RenYuanBiao.ShenFenZhengHao = item0.ShenFenZhengHao;
                            t_RenYuanBiao.JiaTingDiZhi = item0.JiaTingDiZhi;
                            t_RenYuanBiao.XueLi = item0.XueLi;
                            YuanGongList1.Add(t_RenYuanBiao);
                        }
                        returnForGenJinDaoFangTongJis.Add(new ReturnForGenJinDaoFangTongJi { PeopleType = "公司领导", ZhiYeGuWens = YuanGongList0, YeWuYuans = YuanGongList1 });
                    }
                    else
                    {
                        var BuMenLingDaoList = RenYuanList.Where(x => x.t_GangWeiBiao.t_BuMenBiao.BuMenMingCheng == "销售部").ToList();
                        BuMenLingDaoList = BuMenLingDaoList.Where(x => x.t_GangWeiBiao.GangWeiMingCheng.Contains("总监") || x.t_GangWeiBiao.GangWeiMingCheng.Contains("经理")).ToList();
                        var IfBuMenLingDaoHasLoginPeopleList = BuMenLingDaoList.Where(x => x.Id == LoginId).ToList();
                        if (IfBuMenLingDaoHasLoginPeopleList.Count > 0)
                        {
                            var allyewuyuan = RenYuanList.Where(x => x.t_GangWeiBiao.GangWeiMingCheng == "业务员").ToList();
                            var YuanGongList = new List<t_RenYuanBiao>();
                            foreach (var item0 in allyewuyuan)
                            {
                                t_RenYuanBiao t_RenYuanBiao = new t_RenYuanBiao();
                                t_RenYuanBiao.Id = item0.Id;
                                t_RenYuanBiao.XingMing = item0.XingMing;
                                t_RenYuanBiao.ZhangHao = item0.ZhangHao;
                                t_RenYuanBiao.MiMa = item0.MiMa;
                                t_RenYuanBiao.NianLing = item0.NianLing;
                                t_RenYuanBiao.XingBie = item0.XingBie;
                                t_RenYuanBiao.LianXiFangShi = item0.LianXiFangShi;
                                t_RenYuanBiao.GangWeiId = item0.GangWeiId;
                                t_RenYuanBiao.ZhanQuId = item0.ZhanQuId;
                                t_RenYuanBiao.ZhanDuiId = item0.ZhanDuiId;
                                t_RenYuanBiao.ZhuangTai = item0.ZhuangTai;
                                t_RenYuanBiao.XingJi = item0.XingJi;
                                t_RenYuanBiao.HunYinZhuangKuang = item0.HunYinZhuangKuang;
                                t_RenYuanBiao.WeiXinHao = item0.WeiXinHao;
                                t_RenYuanBiao.YouXiang = item0.YouXiang;
                                t_RenYuanBiao.ShenFenZhengHao = item0.ShenFenZhengHao;
                                t_RenYuanBiao.JiaTingDiZhi = item0.JiaTingDiZhi;
                                t_RenYuanBiao.XueLi = item0.XueLi;
                                YuanGongList.Add(t_RenYuanBiao);
                            }
                            returnForGenJinDaoFangTongJis.Add(new ReturnForGenJinDaoFangTongJi { PeopleType = "部门领导", YeWuYuans = YuanGongList });
                        }
                    }
                }
                var xiaoshouxiangxilistzanshi = xiaoshouxiangxilist.Where(x => Convert.ToDateTime(x.CaoZuoShiJian) < EndTime && Convert.ToDateTime(x.CaoZuoShiJian) > StartTime).ToList();
                if (returnForGenJinDaoFangTongJis.Count > 0)
                {
                    if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                    {
                        foreach (var item0 in returnForGenJinDaoFangTongJis[i].YeWuYuans)
                        {
                            item0.BeiZhu9 = (Convert.ToInt32(item0.BeiZhu9) + xiaoshouxiangxilistzanshi.Where(x => x.CaoZuoRen == item0.Id && x.XiaoShouDongZuo == "跟进").ToList().Count).ToString();
                            item0.BeiZhu10 = (Convert.ToInt32(item0.BeiZhu10) + xiaoshouxiangxilistzanshi.Where(x => x.t_XiaoShouBiao.YeWuYuanId == item0.Id && x.XiaoShouDongZuo == "确认到访").ToList().Count).ToString();
                        }
                    }
                    if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                    {
                        foreach (var item0 in returnForGenJinDaoFangTongJis[i].ZhiYeGuWens)
                        {
                            item0.BeiZhu9 = (Convert.ToInt32(item0.BeiZhu9) + xiaoshouxiangxilistzanshi.Where(x => x.CaoZuoRen == item0.Id && x.XiaoShouDongZuo == "跟进").ToList().Count).ToString();
                            item0.BeiZhu10 = (Convert.ToInt32(item0.BeiZhu10) + xiaoshouxiangxilistzanshi.Where(x => x.t_XiaoShouBiao.ZhiYeGuWenId == item0.Id && x.XiaoShouDongZuo == "确认到访" && x.t_XiaoShouBiao.t_KeHuBiao.RenYuanId == item0.Id).ToList().Count).ToString();
                        }
                    }
                }
                if (i == 0)
                {
                    if (returnForGenJinDaoFangTongJis.Count > 0)
                    {
                        if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].YeWuYuans.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByDayYeWuYuan = returnForGenJinDaoFangTongJis[i].GenJinShuByDayYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuByDayYeWuYuan = returnForGenJinDaoFangTongJis[i].DaoFangShuByDayYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu10);
                            }
                        }
                        if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByDayZhiYeGuWen = returnForGenJinDaoFangTongJis[i].GenJinShuByDayZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuByDayZhiYeGuWen = returnForGenJinDaoFangTongJis[i].DaoFangShuByDayZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu10);
                            }
                        }
                    }
                }
                else if (i == 1)
                {
                    if (returnForGenJinDaoFangTongJis.Count > 0)
                    {
                        if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].YeWuYuans.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByWeekYeWuYuan = returnForGenJinDaoFangTongJis[i].GenJinShuByWeekYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuuByWeekYeWuYuan = returnForGenJinDaoFangTongJis[i].DaoFangShuuByWeekYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu10);
                            }
                        }
                        if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByWeekZhiYeGuWen = returnForGenJinDaoFangTongJis[i].GenJinShuByWeekZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuuByWeekZhiYeGuWen = returnForGenJinDaoFangTongJis[i].DaoFangShuuByWeekZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu10);
                            }
                        }
                    }
                }
                else
                {
                    if (returnForGenJinDaoFangTongJis.Count > 0)
                    {
                        if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].YeWuYuans.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByMonthYeWuYuan = returnForGenJinDaoFangTongJis[i].GenJinShuByMonthYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuByMonthYeWuYuan = returnForGenJinDaoFangTongJis[i].DaoFangShuByMonthYeWuYuan + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].YeWuYuans[z].BeiZhu10);
                            }
                        }
                        if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                        {
                            for (int z = 0; z < returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Count; z++)
                            {
                                returnForGenJinDaoFangTongJis[i].GenJinShuByMonthZhiYeGuWen = returnForGenJinDaoFangTongJis[i].GenJinShuByMonthZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu9);
                                returnForGenJinDaoFangTongJis[i].DaoFangShuByMonthZhiYeGuWen = returnForGenJinDaoFangTongJis[i].DaoFangShuByMonthZhiYeGuWen + Convert.ToInt32(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[z].BeiZhu10);
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < returnForGenJinDaoFangTongJis.Count; i++)
            {
                if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                {
                    for (int j = 0; j < returnForGenJinDaoFangTongJis[i].YeWuYuans.Count; j++)
                    {
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_GangWeiBiao = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_TuanDuiRenYuanGuanLianBiaos = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_ZhanDuiBiao = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_XiaoShouBiao_ZhiYeGuWens = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_XiaoShouXiangXiBiao_CaoZuoRens = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_XiaoShouXiangXiBiao_QueRenDaoFangRens = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_TuanDuiBiaos = null;
                        returnForGenJinDaoFangTongJis[i].YeWuYuans[j].t_XiaoShouBiao_YeWuYuans = null;
                    }
                    for (int j = returnForGenJinDaoFangTongJis[i].YeWuYuans.Count - 1; j >= 0; j--)
                    {
                        if (returnForGenJinDaoFangTongJis[i].YeWuYuans[j].BeiZhu9 == "0" && returnForGenJinDaoFangTongJis[i].YeWuYuans[j].BeiZhu10 == "0")
                        {
                            returnForGenJinDaoFangTongJis[i].YeWuYuans.Remove(returnForGenJinDaoFangTongJis[i].YeWuYuans[j]);
                        }
                    }
                }
                if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                {
                    for (int j = 0; j < returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Count; j++)
                    {
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_GangWeiBiao = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_TuanDuiRenYuanGuanLianBiaos = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_ZhanDuiBiao = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_XiaoShouBiao_ZhiYeGuWens = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_XiaoShouXiangXiBiao_CaoZuoRens = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_XiaoShouXiangXiBiao_QueRenDaoFangRens = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_TuanDuiBiaos = null;
                        returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].t_XiaoShouBiao_YeWuYuans = null;
                    }
                    for (int j = returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Count - 1; j >= 0; j--)
                    {
                        if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].BeiZhu9 == "0" && returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j].BeiZhu10 == "0")
                        {
                            returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Remove(returnForGenJinDaoFangTongJis[i].ZhiYeGuWens[j]);
                        }
                    }
                }
                if (returnForGenJinDaoFangTongJis[i].YeWuYuans != null)
                {
                    returnForGenJinDaoFangTongJis[i].YeWuYuansForDaoFang = returnForGenJinDaoFangTongJis[i].YeWuYuans.Where(x => x.BeiZhu10 != "0").ToList();
                    returnForGenJinDaoFangTongJis[i].YeWuYuansForGenJin = returnForGenJinDaoFangTongJis[i].YeWuYuans.Where(x => x.BeiZhu9 != "0").ToList();
                    returnForGenJinDaoFangTongJis[i].YeWuYuans = null;
                }
                if (returnForGenJinDaoFangTongJis[i].ZhiYeGuWens != null)
                {
                    returnForGenJinDaoFangTongJis[i].ZhiYeGuWensForDaoFang = returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Where(x => x.BeiZhu10 != "0").ToList();
                    returnForGenJinDaoFangTongJis[i].ZhiYeGuWensForGenJin = returnForGenJinDaoFangTongJis[i].ZhiYeGuWens.Where(x => x.BeiZhu9 != "0").ToList();
                    returnForGenJinDaoFangTongJis[i].ZhiYeGuWens = null;
                }
            }
            return JsonConvert.SerializeObject(returnForGenJinDaoFangTongJis, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
        }
    }
    class ReturnList
    {
        public string Name { get; set; }
        public int Max { get; set; }
        public int Min { get; set; }
    }
    class ReturnForGenJinDaoFangTongJi
    {
        public string PeopleType { get; set; }
        public List<t_RenYuanBiao> YeWuYuans { get; set; }
        public List<t_RenYuanBiao> YeWuYuansForGenJin { get; set; }
        public List<t_RenYuanBiao> YeWuYuansForDaoFang { get; set; }
        public List<t_RenYuanBiao> ZhiYeGuWens { get; set; }
        public List<t_RenYuanBiao> ZhiYeGuWensForGenJin { get; set; }
        public List<t_RenYuanBiao> ZhiYeGuWensForDaoFang { get; set; }
        public int GenJinShuByMonthYeWuYuan { get; set; }
        public int DaoFangShuByMonthYeWuYuan { get; set; }
        public int GenJinShuByWeekYeWuYuan { get; set; }
        public int DaoFangShuuByWeekYeWuYuan { get; set; }
        public int GenJinShuByDayYeWuYuan { get; set; }
        public int DaoFangShuByDayYeWuYuan { get; set; }
        public int GenJinShuByMonthZhiYeGuWen { get; set; }
        public int DaoFangShuByMonthZhiYeGuWen { get; set; }
        public int GenJinShuByWeekZhiYeGuWen { get; set; }
        public int DaoFangShuuByWeekZhiYeGuWen { get; set; }
        public int GenJinShuByDayZhiYeGuWen { get; set; }
        public int DaoFangShuByDayZhiYeGuWen { get; set; }
    }
}
